package esya;

import java.sql.SQLException;

public class ProcessInp {
	
	//String inpStr = "ee n stocks";
	
	public String process(String s) throws ClassNotFoundException, SQLException{
		
		StringBuffer reply=new StringBuffer();
		boolean flag=false;
		Query q=new Query();
		
		String[] s1=s.split(" ");
		//System.out.println(s1);
		int len=s1.length;
		
		if(s1[0].compareToIgnoreCase("ee")==0){
			flag=true;
			//System.out.println("flag is true"); 
		}
		
		String result;
		if(flag==true){
		for (int i=1;i<len;i=i+2){
			char c = s1[i].charAt(0);
			String qry = s1[i+1];
			
			if(c=='n'){
				reply=reply.append(q.nameQuery(qry)); 
			}
			else if(c=='v'){
				reply=reply.append(q.venueQuery(qry));
			}
			else if(c=='t'){
				reply=reply.append(q.timeQuery(qry)); 
			}
			else if(c=='d'){
				reply=reply.append(q.dateQuery(qry));
			}
		}
		
		result=reply.toString();
		//System.out.println(result);
		//return result;
		}
		else result = "Sorry, invalid input, Try prefixing EE";
		
		return result;
	}
	

}
